﻿
namespace KinonekoSoftware.CodariaDB.Documents.Story
{
    /// <summary>
    /// <see cref="Branch"/> 类型是已经确定的StoryPoint的集合。
    /// </summary>
    public sealed class Branch : RootObject
    {
        private string _name;
        private string _intro;
        private string _color;

        /// <summary>
        /// 获取或设置 <see cref="Color"/> 属性。
        /// </summary>
        public string Color
        {
            get => _color;
            set => SetValue(ref _color, value);
        }
        
        /// <summary>
        /// 获取或设置 <see cref="Intro"/> 属性。
        /// </summary>
        public string Intro
        {
            get => _intro;
            set => SetValue(ref _intro, value);
        }
        
        /// <summary>
        /// 获取或设置 <see cref="Name"/> 属性。
        /// </summary>
        public string Name
        {
            get => _name;
            set => SetValue(ref _name, value);
        }

        [BsonIgnore]
        [JsonIgnore]
        public bool IsValid => !string.IsNullOrEmpty(StartID) && !string.IsNullOrEmpty(EndID);

        public string StartID { get; set; }
        public string EndID   { get; set; }

        [BsonIgnore]
        [JsonIgnore]
        public int Version { get; internal set; }

        /// <summary>
        /// 决定当前分支的序号。
        /// </summary>
        /// <remarks>
        /// <para>当值 &gt; -1，不启用自动排序。</para>
        /// <para>当值 &lt; 0, 启用自动排序。</para>
        /// </remarks>
        public int Index { get; set; }

    }
}